package May;

import java.util.Scanner;

public class Test08Loop01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请你输入一个数字，我将判断他是否为质数或者合数：");
        int number = sc.nextInt();
        if (number <= 3) {
            if (number <= 1) {
                System.out.println(number + "不是质数也不是合数");
            } else {
                System.out.println(number + "是质数");
            }
        } else {
            if (number % 6 == 1 || number % 6 == 5) {
                boolean flag = true;
                int sqrNum = (int) Math.sqrt(number);
//                for (int i = 5; i <= sqrNum; i += 6) {
//                    if (number % i == 0 || number % (i + 2) == 0) {
//                        flag = false;
//                        break;
//                    }
//                }
                if (flag) {
                    System.out.println(number + "是质数");
                    System.out.println("number的值为："+number+"sqrNum（平方根的值为）："+sqrNum);
                } else {
                    System.out.println(number + "是合数");
                }
            } else {
                System.out.println(number + "是合数");
            }
        }
        sc.close();

    }
}




